﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>统一认证中心</title>
    <meta name="keywords" content="登录界面下载,登录界面样式,响应式登录界面下载,会员登录模板下载,后台登录界面,注册模板下载,html注册界面"/>
    <meta name="description" content="本栏目收集各种登录界面。登录界面下载、登录界面样式、响应式登录界面下载、注册模板下载、html注册界面、会员登录模板下载、后台登录界面"/>
    <link rel="stylesheet" href="/static/v1/css/rbac/style.css"/>
    <link rel="stylesheet" href="/static/v1/css/rbac/icon.css"/>
</head>

<body>
<div id="wrapper">
    <div class="aw-login-box">
        <div class="box-bg-ys"></div>
        <div class="mod-body clearfix">
            <div class="content pull-left">
                <h1 class="logo"><a href=""></a></h1>
                <form id="login_form" method="post" onSubmit="return false" action="javascript:;">
                    <input type="hidden" name="return_url" value="0">
                    <ul>
                        <li>
                            <input type="text" id="aw-login-user-name" class="form-control" placeholder="邮箱"
                                   name="userName">
                        </li>
                        <li>
                            <input type="password" id="aw-login-user-password" class="form-control" placeholder="密码"
                                   name="passWord">
                        </li>
                        <!--                         <li class="alert alert-danger hide error_message">-->
                        <!--                            <i class="icon icon-delete"></i> <em></em>-->
                        <!--                        </li>-->
                        <li class="last">
                            <a href="javascript:;" class="pull-right btn btn-large btn-primary btn-submit">登录</a>
                            <label>
                                <input type="checkbox" value="1" name="net_auto_login">
                                记住我 </label>
                            &nbsp;&nbsp;| <a href="javascript:;">&nbsp;&nbsp;忘记密码</a>
                        </li>
                    </ul>
                </form>
            </div>
            <div class="side-bar pull-left">
                <h3>第三方账号登录</h3>
                <a href="javascript:;" class="btn btn-block btn-weibo"><i class="icon icon-weibo"></i> MobileGroup</a>
                <a href="javascript:;" class="btn btn-block btn-qq"> <i class="icon icon-qq"></i> 微信扫码登录</a>
            </div>
        </div>
        <div class="mod-footer">
            <span>还没有账号?</span>&nbsp;&nbsp;
            <a href="javascript:;">立即注册</a>&nbsp;&nbsp;•&nbsp;&nbsp;
            <a href="javascript:;">游客访问</a>&nbsp;&nbsp;
        </div>
    </div>
</div>

<script src="/static/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.use(['layer', 'form', 'layedit'], function () {
        var layer = layui.layer
            , form = layui.form;
        var $ = layui.$;


        $(".btn-submit").on("click", function () {

            var userName = $('[name=userName]').val();
            var passWord = $('[name=passWord]').val();
            if (userName == '' || passWord == '') {
                layer.msg("填写内容不能为空！");
                return;
            }
            var loadIndex = layer.load(1); //换了种风格
            $.ajax({
                url: "/rest/user/login",
                type: "post",
                data: {
                    userName: userName,
                    passWord: passWord
                },
                dataType: "json",
                success: function (data) {
                    if (data.code == '200') {
                        layer.msg("登录成功");
                        //请求成功后，写入 access_token
                        layui.data("hao-tool-token", {
                            key: "accessToken"
                            , value: data.data.accessToken
                        });
                        window.location = "/";
                    } else {
                        var msg = data.msg != '' ? data.msg : "登录失败";
                        layer.msg(msg);
                    }
                }, complete: function () {
                    layer.close(loadIndex);
                }
            });
        })
    });
</script>
</body>
</html>